'use strict';

//To support syntax defined in http://arduino.cc/en/Reference/HomePage

goog.provide('Blockly.Blocks.servo');

goog.require('Blockly.Blocks');

Blockly.Blocks['servo_move'] = {
  init: function() {
    this.jsonInit({
      "type": "servo_move",
      "message0": "%{BKY_SERVO_MOVE_MSG}",
      "args0": [
        {
          "type": "field_image",
          "src": "/static/blockly/media/EMAX%20Servo.jpg",
          "width": 64,
          "height": 64,
          "alt": "*"
        },
        {
          "type": "input_dummy"
        },
        {
          "type": "input_value",
          "name": "PIN",
          "check": "String",
          "align": "RIGHT"
        },
        {
          "type": "input_value",
          "name": "DEGREE",
          "check": "Number"
        }
      ],
      "inputsInline": true,
      "previousStatement": null,
      "nextStatement": null,
      "extensions": ["colours_event", "shape_statement"]
    });
  }
};


Blockly.Blocks['servo_read_degrees'] = {
  init: function() {
    this.jsonInit({
      "type": "servo_read_degrees",
      "message0": "%{BKY_SERVO_READ_DEGREES_MSG}",
      "args0": [
        {
          "type": "field_image",
          "src": "/static/blockly/media/EMAX%20Servo.jpg",
          "width": 64,
          "height": 64,
          "alt": "*"
        },
        {
          "type": "input_dummy"
        },
        {
          "type": "input_value",
          "name": "PIN",
          "check": "String",
          "align": "RIGHT"
        }
      ],
      "inputsInline": true,
      "output": "Number",
      "extensions": ["colours_event", "output_number"]
    });
  }
};


Blockly.Blocks['green_servo_move'] = {
  init: function() {
    this.jsonInit({
      "type": "green_servo_move",
      "message0": "%{BKY_COLOUR_SERVO_MOVE_MSG}",
      "args0": [
        {
          "type": "field_image",
          "src": "/static/blockly/media/EMAX%20Servo.jpg",
          "width": 64,
          "height": 64,
          "alt": "*"
        },
        {
          "type": "input_dummy"
        },
        {
          "type": "input_value",
          "name": "DEGREE",
          "check": "Number"
        }
      ],
      "inputsInline": true,
      "previousStatement": null,
      "nextStatement": null,
      "extensions": ["colours_servo_green", "shape_statement"]
    });
  }
};


Blockly.Blocks['white_servo_move'] = {
  init: function() {
    this.jsonInit({
      "type": "white_servo_move",
      "message0": "%{BKY_COLOUR_SERVO_MOVE_MSG}",
      "args0": [
        {
          "type": "field_image",
          "src": "/static/blockly/media/EMAX%20Servo.jpg",
          "width": 64,
          "height": 64,
          "alt": "*"
        },
        {
          "type": "input_dummy"
        },
        {
          "type": "input_value",
          "name": "DEGREE",
          "check": "Number"
        }
      ],
      "inputsInline": true,
      "previousStatement": null,
      "nextStatement": null,
      "extensions": ["colours_event", "shape_statement"]
    });
  }
};

Blockly.Blocks['blue_servo_move'] = {
  init: function() {
    this.jsonInit({
      "type": "blue_servo_move",
      "message0": "%{BKY_COLOUR_SERVO_MOVE_MSG}",
      "args0": [
        {
          "type": "field_image",
          "src": "/static/blockly/media/EMAX%20Servo.jpg",
          "width": 64,
          "height": 64,
          "alt": "*"
        },
        {
          "type": "input_dummy"
        },
        {
          "type": "input_value",
          "name": "DEGREE",
          "check": "Number"
        }
      ],
      "inputsInline": true,
      "previousStatement": null,
      "nextStatement": null,
      "extensions": ["colours_servo_blue", "shape_statement"]
    });
  }
};

Blockly.Blocks['black_servo_move'] = {
  init: function() {
    this.jsonInit({
      "type": "black_servo_move",
      "message0": "%{BKY_COLOUR_SERVO_MOVE_MSG}",
      "args0": [
        {
          "type": "field_image",
          "src": "/static/blockly/media/EMAX%20Servo.jpg",
          "width": 64,
          "height": 64,
          "alt": "*"
        },
        {
          "type": "input_dummy"
        },
        {
          "type": "input_value",
          "name": "DEGREE",
          "check": "Number"
        }
      ],
      "inputsInline": true,
      "previousStatement": null,
      "nextStatement": null,
      "extensions": ["colours_servo_black", "shape_statement"]
    });
  }
};


Blockly.Blocks['red_servo_move'] = {
  init: function() {
    this.jsonInit({
      "type": "red_servo_move",
      "message0": "%{BKY_COLOUR_SERVO_MOVE_MSG}",
      "args0": [
        {
          "type": "field_image",
          "src": "/static/blockly/media/EMAX%20Servo.jpg",
          "width": 64,
          "height": 64,
          "alt": "*"
        },
        {
          "type": "input_dummy"
        },
        {
          "type": "input_value",
          "name": "DEGREE",
          "check": "Number"
        }
      ],
      "inputsInline": true,
      "previousStatement": null,
      "nextStatement": null,
      "extensions": ["colours_servo_red", "shape_statement"]
    });
  }
};
